package drafts_config

import (
	"news_for_deepseek_interface/controller"
	"news_for_deepseek_interface/dto"
	draftsConfigDto "news_for_deepseek_interface/dto/admin/drafts_config"
	draftsConfigService "news_for_deepseek_interface/service/admin/drafts_config"

	"github.com/gin-gonic/gin"
)

func Count(c *gin.Context) {

	//1. 参数绑定
	var params draftsConfigDto.CountRequest
	if err := c.ShouldBindJSON(&params); err != nil {
		controller.Fail(c, controller.ParamsError, err.Error())
		return
	}

	//2. 验证参数
	if err := dto.Validate(params); err != nil {
		controller.Fail(c, controller.ParamsError, err.Error())
		return
	}

	//3. 调用服务层处理登录逻辑
	count, err := draftsConfigService.Count(params)
	if err != nil {
		controller.Fail(c, controller.BusinessError, "获取配置失败："+err.Error())
		return
	}

	controller.Success(c, count)
}
